home *** CD-ROM | disk | FTP | other *** search
- /*
- This simple extension of the java.awt.Frame class
- contains all the elements necessary to act as the
- main window of an application.
- */
-
- import java.awt.*;
-
- public class Frame1 extends Frame {
- void Open_Action(Event event) {
- //{{CONNECTION
- // Action from Open... Show the OpenFileDialog
- openFileDialog1.show();
- //}}
- }
-
- void About_Action(Event event) {
- //{{CONNECTION
- // Action from About Create and show as modal
- (new AboutDialog(this, true)).show();
- //}}
- }
-
- void Exit_Action(Event event) {
- //{{CONNECTION
- // Action from Exit Create and show as modal
- (new QuitDialog(this, true)).show();
- //}}
- }
-
- public Frame1() {
-
- //{{INIT_CONTROLS
- setLayout(null);
- // addNotify();
- resize(insets().left + insets().right + 405,insets().top + insets().bottom + 305);
- openFileDialog1 = new java.awt.FileDialog(this, "Open",FileDialog.LOAD);
- //$$ openFileDialog1.move(37,277);
- setTitle("A Basic Application");
- //}}
-
- //{{INIT_MENUS
- mainMenuBar = new java.awt.MenuBar();
-
- menu1 = new java.awt.Menu("File");
- menu1.add("New");
- menu1.add("Open...");
- menu1.add("Save");
- menu1.add("Save As...");
- menu1.addSeparator();
- menu1.add("Exit");
- mainMenuBar.add(menu1);
-
- menu2 = new java.awt.Menu("Edit");
- menu2.add("Cut");
- menu2.add("Copy");
- menu2.add("Paste");
- mainMenuBar.add(menu2);
-
- menu3 = new java.awt.Menu("Help");
- mainMenuBar.setHelpMenu(menu3);
- menu3.add("About");
- mainMenuBar.add(menu3);
- setMenuBar(mainMenuBar);
- //$$ mainMenuBar.move(4,277);
- //}}
- }
-
- public Frame1(String title) {
- this();
- setTitle(title);
- }
-
- public synchronized void show() {
- move(50, 50);
- super.show();
- }
-
- public boolean handleEvent(Event event) {
- if (event.id == Event.WINDOW_DESTROY) {
- hide(); // hide the Frame
- dispose(); // free the system resources
- System.exit(0); // close the application
- return true;
- }
- return super.handleEvent(event);
- }
-
- public boolean action(Event event, Object arg) {
- if (event.target instanceof MenuItem) {
- String label = (String) arg;
- if (label.equalsIgnoreCase("Open...")) {
- Open_Action(event);
- return true;
- } else
- if (label.equalsIgnoreCase("About")) {
- About_Action(event);
- return true;
- } else
- if (label.equalsIgnoreCase("Exit")) {
- Exit_Action(event);
- return true;
- }
- }
- return super.action(event, arg);
- }
-
- static public void main(String args[]) {
- (new Frame1()).show();
- }
-
- //{{DECLARE_CONTROLS
- java.awt.FileDialog openFileDialog1;
- //}}
-
- //{{DECLARE_MENUS
- java.awt.MenuBar mainMenuBar;
- java.awt.Menu menu1;
- java.awt.Menu menu2;
- java.awt.Menu menu3;
- //}}
- }
-